home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-01-30 | 3.6 KB | 97 lines | [TEXT/ToyS] |
- property desc : "Drop one or more files on my application icon to change their creators and/or types.
-
- Copyright © 1996-1998 Christopher E. Hyde.
- All rights reserved.
- Email: drjekyll@hylight.demon.co.uk"
- property txt : "TEXT"
- property appList : ["MPW", "ToolServer", "SPM", "BBEdit", "CodeWarrior", "Simple Text", "Claris Works", "MS Word", "Other:", ¬
- "Script Editor", "Script Debug’r", "Scripter", "Navigator", "ResEdit"] -- Append up to 4 more application/creator/types
- property cList : ["MPS ", "MPSX", "SPM ", "R*ch", "CWIE", "ttxt", "BOBO", "MSWD", null, "ToyS", "asDB", "MEme", "MOSS", "RSED", 15, 16, 17, 18]
- property tList : [txt, txt, txt, txt, txt, txt, txt, txt, null, txt, txt, txt, txt, "rsrc"]
- property opt : 6
- property doCreat : true
- property doType : true
- property dlogBounds : null
-
- global fileList
- open []
-
- on open aFileList
- if (dd count dialogs) = 0 then
- DoDialog(aFileList)
- else
- SetFiles(fileList & aFileList)
- end if
- end open
-
- on DoDialog(aFileList)
- SetFiles(aFileList)
- try
- repeat
- set i to dd interact with user
- if i = 3 then
- DoChange()
- SetFiles([])
- else if i = 4 then
- SetFiles([])
- else if i = -1 then
- set [opt, _, _, doCreat, doType] to dd get value of items 5 thru 9 of dialog 1
- set dlogBounds to dd get bounds of dialog 1
- exit repeat
- end if
- end repeat
- on error (*m number n from f to T partial result p
- dd uninstall
- display dialog m & " Code = " & n
- error m number n from f to T partial result p*)
- end try
- dd uninstall
- end DoDialog
-
- on SetFiles(aFileList)
- set fileList to aFileList
- if (dd count dialogs) = 0 then
- dd install with fonts [null, null, null, null, {name:"Geneva", size:9}] with grayscale
- if dlogBounds = null then set dlogBounds to dd calc dialog bounds [260, 330]
- dd make dialog {bounds:dlogBounds, name:"Set File Creator & Type", style:standard window, closeable:true, contents:[¬
- {class:dummy, enabled:false}, ¬
- {class:dummy, enabled:[dOr, 8, 9]}, ¬
- {class:push button, bounds:[190, 300, 250, 320], name:"Change", enabled:[dAnd, 1, 2]}, ¬
- {class:push button, bounds:[10, 300, 90, 320], name:"Clear Files", enabled:1}, ¬
- {class:radio group, bounds:[10, 60, 120, 76], button offset:[120, 20], max down:9, value:opt, contents:appList}, ¬
- {class:text field, name:"Creator", name bounds:[30, 240, 85, 256], bounds:[90, 240, 140, 256], enabled:[dAnd, 5 + 9 * 256, 8]}, ¬
- {class:text field, name:"Type", name bounds:[155, 240, 190, 256], bounds:[195, 240, 245, 256], enabled:[dAnd, 5 + 9 * 256, 9]}, ¬
- {class:check box, bounds:[30, 265, 140, 281], name:"Set Creator", value:doCreat}, ¬
- {class:check box, bounds:[155, 265, 260, 281], name:"Set Type", value:doType}, ¬
- {class:group box, bounds:[8, 8, 252, 40], style:secondary group}, ¬
- {class:static text, bounds:[12, 12, 248, 36], font:5, contents:""} ¬
- ]}
- end if
- set n to fileList's length
- dd set enabled of item 1 of dialog 1 to n ≠ 0
- if n ≠ 0 then
- dd set contents of item 11 of dialog 1 to "Change the file creators and/or types of the " & n & " files that were dropped on me."
- set f to info for (fileList's item 1)
- dd set value of items 6 thru 7 of dialog 1 to [f's file creator, f's file type]
- else
- dd set contents of item 11 of dialog 1 to desc
- end if
- end SetFiles
-
- on DoChange()
- try
- set [opt, c, T, doCreat, doType] to dd get value of items 5 thru 9 of dialog 1
- if opt ≠ 9 then
- set c to item opt of cList
- set T to item opt of tList
- end if
- tell application "Finder"
- repeat with f in fileList
- if doCreat then set creator type of f to c
- if doType then set file type of f to T
- end repeat
- end tell
- on error
- beep
- end try
- end DoChange